//index.js
//获取应用实例
var app = getApp()
Page({
  data: {
    motto: 'Hello 卢浩',
    userInfo: {},
    background: null,
    indicatorDots: true,
    vertical: false,
    autoplay: true,
    interval: 3000,
    duration: 1200
  },
  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  bindViewTap1: function() {
    wx.request({
      url: 'https://www.zhaoyg.cn/index/test',
      data: {},
      method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
      // header: {}, // 设置请求的 header
      success: function(res){
        // success
        console.log(res)
      },
      fail: function() {
        // fail
      },
      complete: function() {
        // complete
        console.log('load over')
      }
    })
  },
  changeIndicatorDots: function (e) {
    this.setData({
      indicatorDots: !this.data.indicatorDots
    })
  },
  changeVertical: function (e) {
    this.setData({
      vertical: !this.data.vertical
    })
  },
  changeAutoplay: function (e) {
    this.setData({
      autoplay: !this.data.autoplay
    })
  },
  intervalChange: function (e) {
    this.setData({
      interval: e.detail.value
    })
  },
  durationChange: function (e) {
    this.setData({
      duration: e.detail.value
    })
  },
  onLoad: function () {
    // console.log('onLoad')
      var that = this
    // //调用应用实例的方法获取全局数据
    // app.getUserInfo(function(userInfo){
    //   //更新数据
    //   if(userInfo.gender==1){
    //   userInfo.gender='男'
    //   }else{
    //   userInfo.gender='女'
    //   }
    //   if(userInfo.country=='CN'){
    //   userInfo.country='中国'
    //   }else{
    //   userInfo.country='其他国家'
    //   }
    //   that.setData({
    //     userInfo:userInfo
    //   })
    // })
    wx.request({
      url: 'https://www.zhaoyg.cn/index/test',
      data: {},
      method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
      // header: {}, // 设置请求的 header
      success: function(res){
        // success
        that.setData({
          background: res.data
        })
      },
      fail: function() {
        // fail
      },
      complete: function() {
        // complete
      }
    })

  }
})
